import { defineConfig } from "vitepress";
import { whyframe } from '@whyframe/core'
import { whyframeVue } from '@whyframe/vue'

// https://vitepress.dev/reference/site-config
export default defineConfig({
  // iframe配置
  vite: {
    plugins: [
      // Initialize core plugin
      whyframe({
        defaultSrc: '/frames/default' // provide our own html
      }),

      // Initialize Vue integration plugin
      whyframeVue({
        include: /\.(?:vue|md)$/ // also scan in markdown files
      })
    ]
  },
  base: '/vitepress/',
  title: "百业通uniapp组件文档",
  description: "封装uniapp三端常用组件",
  head: [["link", { rel: "icon", href: "/vite.svg" }]],
  // 启用全局页面右下角最新更新时间
  lastUpdated: true,
  // 国际化配置
  // locales: {
  //   root: {
  //     label: "英语",
  //     lang: "en",
  //   },
  //   fr: {
  //     label: "中文",
  //     lang: "zh", // 可选，将作为 `lang` 属性添加到 `html` 标签中
  //     link: "/fr/foo", // 默认 /fr/ -- 显示在导航栏翻译菜单上，可以是外部的
  //     // 其余 locale 特定属性...
  //   },
  // },
  // 导航栏配置
  themeConfig: {
    logo: "/vite.svg",
    // 文档卡片默认文字
    markdown: {
      container: {
        tipLabel: '提示',
        warningLabel: '警告',
        dangerLabel: '危险',
        infoLabel: '信息',
        detailsLabel: '详细信息'
      }
    },
    // 上一页下一页标题
    docFooter: {
      prev: "上一页",
      next: "下一页",
    },
    // 禁用全局大纲
    outline: {
      label: "页面导航",
    },
    // 开启搜索
    search: {
      provider: "local",
      options: {
        locales: {
          root: {
            placeholder: "搜索文档",
            translations: {
              button: {
                buttonText: "搜索文档",
                buttonAriaLabel: "搜索文档",
              },
              modal: {
                noResultsText: '无法找到相关结果',
                resetButtonTitle: '清除查询条件',
                // @ts-ignore
                searchBox: {
                  resetButtonTitle: "清除查询条件",
                  resetButtonAriaLabel: "清除查询条件",
                  cancelButtonText: "取消",
                  cancelButtonAriaLabel: "取消",
                },
                startScreen: {
                  recentSearchesTitle: "搜索历史",
                  noRecentSearchesText: "没有搜索历史",
                  saveRecentSearchButtonTitle: "保存至搜索历史",
                  removeRecentSearchButtonTitle: "从搜索历史中移除",
                  favoriteSearchesTitle: "收藏",
                  removeFavoriteSearchButtonTitle: "从收藏中移除",
                },
                errorScreen: {
                  titleText: "无法获取结果",
                  helpText: "你可能需要检查你的网络连接",
                },
                footer: {
                  selectText: "选择",
                  navigateText: "切换",
                  closeText: "关闭",
                },
                noResultsScreen: {
                  noResultsText: "无法找到相关结果",
                  suggestedQueryText: "你可以尝试查询",
                  reportMissingResultsText: "你认为该查询应该有结果？",
                  reportMissingResultsLinkText: "点击反馈",
                },
              },
            },
          },
        },
      },
    },
    // 最后更新时间
    lastUpdated: {
      text: "最后更新时间",
      formatOptions: {
        dateStyle: "full",
        timeStyle: "medium",
      },
    },
    nav: [
      { text: "首页", link: "/" },
      { text: "查看文档", link: "/view/markdown-examples" },
    ],
    // 侧边栏配置
    sidebar: [
      {
        text: "示例",
        items: [
          { text: "使用示例", link: "/view/markdown-examples" },
          { text: "API示例", link: "/view/api-examples" },
          { text: "页面渲染vue组件", link: "/view/myhome" },
          { text: "开发成员页", link: "/view/member" },
        ],
      },
    ],
    // // 顶部最右侧配置
    // socialLinks: [
    //   { icon: "github", link: "https://github.com/vuejs/vitepress" },
    // ],
    // 底部配置
    footer: {
      message: "我是首页的底部配置",
      copyright: "请看 © 2019-版本",
    },
    // 全局底部链接配置
    editLink: {
      pattern: ({ filePath }) => {
        console.log("全局底部链接配置", filePath);
        if (filePath.includes("view/markdown-examples.md")) {
          return `http://www.baidu.com`;
        } else {
          return `https://github.com/vuejs/vitepress`;
        }
      },
      text: "这是全局底部链接配置,根据不同页面设置不同链接",
    },
  },
});
